<template>
	<view>
		<map show-location class="map" :latitude="lat" :longitude="lng" :markers="markers">
			<cover-image src="../../../static/imgs/backicon.png" class="icon" @click="back"></cover-image>
			<cover-image src="../../../static/imgs/order-grey.png" class="icon2" @click="nav('./myOrder')"></cover-image>
		</map>
		<view class="container">
			<view class="tab-container">
				<view class="tab-item tab-item-cur"><text class="tab-text">现在</text></view>
				<view class="tab-item"><text class="tab-text">预约</text></view>
				<view class="tab-item"><text class="tab-text">代叫</text></view>
			</view>
			<view class="start-end">
				<view class="start" @click="start"><text class="green"></text>你将在<text
						style="color: green;">庐山酒店</text>上车</view>
				<view class="end end-none" @click="end"><text class="red"></text>你要去哪儿</view>
			</view>
			<view class="history">
				<view class="history-item" @click="nav('./carList')">
					<image src="../../../static/imgs/dingwei.png" class="icon"></image><text
						class="history-text">庐山酒店</text>
				</view>
				<view class="history-item" @click="nav('./carList')">
					<image src="../../../static/imgs/dingwei.png" class="icon"></image><text
						class="history-text">布吉东站</text>
				</view>
				<view class="history-item" @click="nav('./carList')">
					<image src="../../../static/imgs/dingwei.png" class="icon"></image><text
						class="history-text">白云机场</text>
				</view>
			</view>
		</view>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				lat: 0,
				lng: 0,
				markers: []
			};
		},
		onLoad() {
			this.getLocation()
		},
		methods: {
			getLocation() {
				const that = this
				uni.getLocation({
					type: 'gcj02',
					success(e) {
						that.lat = e.latitude
						that.lng = e.longitude
						that.markers = [{
							id: 0,
							latitude: e.latitude,
							longitude: e.longitude,
							iconPath: '/static/imgs/location.png',
							width: 100,
							height: 100
						}]
					}
				})
			},
			callback(e) {},
			start() {
				uni.navigateTo({
					url: './searchAddr?type=start'
				})
			},
			end() {
				uni.navigateTo({
					url: './searchAddr?type=end'
				})
			},
			nav(url) {
				uni.navigateTo({
					url
				})
			},
			back(){
				uni.switchTab({
					url:'../homePage'
				})
			}
		}
	}
</script>
<style lang="scss">
	.map {
		width: 750rpx;
		height: 800rpx;
		border: none;
		outline: none;
		margin: 0;
		padding: 0;

		.icon {
			width: 60rpx;
			height: 60rpx;
			position: absolute;
			left: 20rpx;
			top: calc(var(--status-bar-height) + 20rpx);
		}

		.icon2 {
			width: 60rpx;
			height: 60rpx;
			position: absolute;
			right: 20rpx;
			top: calc(var(--status-bar-height) + 20rpx);
		}
	}

	.container {
		width: 750rpx;
		position: relative;
		background: #FFFFFF;
		height: calc(100vh - 810rpx);
		overflow: scroll;
		border: none;
		outline: none;
		margin: 0;
		padding: 0;

		.tab-container {
			width: 100%;
			display: flex;
			align-items: center;
			justify-content: flex-start;
			border-bottom: 2rpx solid #F2F2F7;
			flex-direction: row;
		}

		.tab-item {
			width: 100rpx;
			height: 80rpx;
			display: flex;
			align-items: center;
			justify-content: center;
			flex-direction: row;
			margin-right: 20rpx;
		}

		.tab-text {
			color: #333333;
			font-size: 28rpx;
		}

		.tab-item-cur {
			border-bottom: 4rpx solid #3587f7;
			font-weight: bold;
		}

		.start-end {
			padding: 0 20rpx;

		}

		.start {
			padding: 30rpx;
			display: flex;
			align-items: center;
			justify-content: flex-start;
			flex-direction: row;
		}

		.start-none {
			background-color: #F2F2F7;
		}

		.end {
			padding: 30rpx;
			display: flex;
			align-items: center;
			justify-content: flex-start;
			flex-direction: row;
		}

		.end-none {
			background-color: #F2F2F7;
		}

		.red {
			width: 15rpx;
			height: 15rpx;
			border-radius: 50%;
			background-color: #FD5C5B;
			margin-right: 10rpx;
		}

		.green {
			width: 15rpx;
			height: 15rpx;
			border-radius: 50%;
			background-color: #49B992;
			margin-right: 10rpx;
		}

		.history {
			display: flex;
			align-items: center;
			justify-content: flex-start;
			flex-direction: row;
			padding: 30rpx;
		}

		.history-item {
			display: flex;
			flex-direction: row;
			align-items: center;
			margin-right: 30rpx;

		}

		.history-item .icon {
			width: 30rpx;
			height: 30rpx;
			margin-right: 10rpx;
		}

		.history-text {
			color: #333333;
			font-size: 28rpx;
		}
	}
</style>
